package com.taoxeo.mqtt;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

import org.junit.Test;

public class MqttBanch {
	private int i = 0;
	
	@Test
	public void banch() throws InterruptedException{
		Executor exe = Executors.newFixedThreadPool(100);
		for(int n = 0; n < 100; n++){
			exe.execute(new Runnable() {
				@Override
				public void run() {
					MQTTClient client =  MQTTClientFactory.create("tcp://push.taoxeo.com:61613", "13774315389", "123456", new String[]{"/topic_test"}, new MessageCallback(){
						@Override
						void messageArrived(String topic, byte[] payload) {
							System.out.println("----"+new String(payload));
						}
					});
					client.connect();
					try {
						Thread.currentThread().sleep(2000);
						while(true){
							
							Thread.currentThread().sleep(1000);
						}
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
				}
			});
		}
		
		Thread.currentThread().join();
	}
}
